#include <iostream>
#include "QuickSort.h"
#include "QuickIterative.h"

using namespace std;

#define ARR_SIZE 12

// The program sorts an array of items with 2 versions of QuickSort:
// 1) A recursive version - named 'QuickSort'
// 2) An recursive version - named 'QuickIterative'
// in a case of an error the program raised and exception and prints an error
// to use the algorithems it is mendatory that the type of the array data,
// will include its own implamentation of the '>' and the '<<' operator

//function that prints the array
void printArray(int* arr)
{
	for (int i=0 ; i < ARR_SIZE-1; i++)
	{
		cout << arr[i] << ", " ;
	}
	cout << arr[ARR_SIZE-1] << endl << endl;
}

void main ()
{	
	int left = 0 , right = ARR_SIZE-1 ;
	
	int arrA[ARR_SIZE] = {23,-2,100,45,-1,0,73,11,9,65,102,1};
	int arrB[ARR_SIZE] = {45,15,24,-42,35,9,12,34,10,-8,10,-6};

	cout << "QuickSort By Recursion and Iterative" << endl;
	cout << "------------------------------------" << endl << endl;
	
	cout << "Array A before the sort: " << endl;
	printArray(arrA);
	cout << "Sorting array A with QuickSort!" << endl;
	QuickSort<int>(arrA, left ,right);
	cout << "Array A sorted: " << endl;
	printArray(arrA);

	cout << "Array B before the sort: " << endl;
	printArray(arrB);
	cout << "Sorting array B with Iterative QuickSort!" << endl;
	try 
	{
		QuickSortIter<int>(arrB, left , right);
	}
	catch (char* error)
	{
		cout << "Exception raised: " << error << endl;
		cout << "I Quit..." << endl;
	}
	cout << "Array B sorted: " << endl;
	printArray(arrB);
}	
